// 导入请求实例

import axios from "./request.js"

export function fetchLunbo() {
    return axios.get('/getlunbo')
}

export function fetchRecommend(page = 1, limit = 10) {
    return axios.get(`/recommend?page=${page}&limit=${limit}`)
}

export function fetchGoodsList(page = 1, limit = 6) {
    return axios.get(`/getgoods?pageindex=${page}&pagesize=${limit}`)
}

//商品详情的轮播图
export function fetchGoodsImages(goodsid) {
    return axios.get(`/getthumbimages/${goodsid}`)
}

// 获取商品的基本信息
export function fetchGoodsInfo(goodsid) {
    return axios.get(`/getgoodsinfo/${goodsid}`)
}

// 获取购物车商品列表
export function fetchCartGoods(ids) {
    return axios.get(`/getshopcarlist/${ids}`)
}

// 商品搜索接口
// 模糊查询商品
export function fetchSearchGoods(data) {
    // 对象 {value:"iphone",'sort':"buy",order:"desc",page:1,pagesiz:10}
    // 将对象转化成查询字符串 
    let queryString = Object.keys(data).map(key => `${key}=${encodeURIComponent(data[key])}`).join('&');
    return axios.get(`/search?${queryString}`)
}

